package com.wc.alorithm_blue_bridge._二分.Q3344;

import java.io.*;

/**
 * @Author congege
 * @Description
 * 可凑成的最大花束数
 *
 * 要想每一个人的花的贡献值
 * https://www.lanqiao.cn/problems/3344/learning/?page=1&first_category_id=1
 * @Date Created in 2023/11/24-22:04
 */
public class Main {
    public static void main(String[] args) {
        Input sc = new Input();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        long left = 0;
        long right = 2 * (long) 1e14;
        long mid;
        while (left <= right) {
            mid = left + (right - left) / 2;
            if (check(mid, array, k)) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        System.out.println(left - 1);
    }

    public static boolean check(long x, int[] array, int k) {
        long res = 0;
        for (int num : array) {
            res += Math.min(x, num);
        }
        return res / k >= x;
    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (Exception e) {
                return -1;
            }
            return (int) in.nval;
        }
    }
}
